$(function() {
		
	// 定义列
	var columns = [
		{
				field : 'no',
				title : '序号',
				align : 'left',
				formatter : function(value, row, index) {
					return index + 1;
				}
		},
		{
				field : 'id',
				title : 'ID',
				align : 'center'
		},
		{
				field : 'orderCode',
				title : '订单编号 ',
				align : 'center'
		},
		{
				field : 'payCode',
				title : '支付流水号',
				align : 'center'
		},
		{
				field : 'payTime',
				title : '支付时间',
				align : 'center'
		},
		{
				field : 'payMoney',
				title : '支付金额 ',
				align : 'center'
		},
		{
				field : 'payType',
				title : '支付方式 ',
				align : 'center'
		},
		{
				field : 'filePath',
				title : '支付凭证',
				align : 'center'
		},
		{
				field : 'accountName',
				title : '账户名称 ',
				align : 'center'
		},
		{
				field : 'bankAccount',
				title : '账号',
				align : 'center'
		},
		{
				field : 'bankName',
				title : '银行',
				align : 'center'
		},
		{
				field : 'openBank',
				title : '开户行 ',
				align : 'center'
		},
		{
				field : 'confirmStatus',
				title : '确认状态',
				align : 'center'
		},
		{
				field : 'approverCoee',
				title : '审核人 ',
				align : 'center'
		},
		{
				field : 'approveResult',
				title : '审批结果',
				align : 'center'
		},
		{
				field : 'aporoveReason',
				title : '审核意见',
				align : 'center'
		},
		{	
			field : '#',
			title : '操作',
			align : 'center',
			formatter : function(value, row, index) {
				if (row.status == "0") {
					return "<a href='javaScript:void(0);'onclick='updateStatus("
								+ row.id
								+ ","
								+ row.status
								+ ")'>启用</a>"
								+ "<a href='javaScript:void(0);'onclick='toEdit("
								+ row.id + ")'>编辑</a>";
				} else if (row.status == "1") {
					return "<a href='javaScript:void(0);'onclick='updateStatus("
								+ row.id
								+ ","
								+ row.status
								+ ")'>停用</a>"
								+ "<a href='javaScript:void(0);'onclick='toEdit("
								+ row.id + ")'>编辑</a>";
				}
			}
		}, ];
			
			
	// 定义查询回调函数（查询参数在此设置）
	var queryParams = function(params) {
	
		var id =  $("#id").val()
		var orderCode =  $("#orderCode").val()
		var payCode =  $("#payCode").val()
		var payTime =  $("#payTime").val()
		var payMoney =  $("#payMoney").val()
		var payType =  $("#payType").val()
		var filePath =  $("#filePath").val()
		var accountName =  $("#accountName").val()
		var bankAccount =  $("#bankAccount").val()
		var bankName =  $("#bankName").val()
		var openBank =  $("#openBank").val()
		var confirmStatus =  $("#confirmStatus").val()
		var approverCoee =  $("#approverCoee").val()
		var approveResult =  $("#approveResult").val()
		var aporoveReason =  $("#aporoveReason").val()
		var approveTie =  $("#approveTie").val()
		var isDelete =  $("#isDelete").val()
		var creater =  $("#creater").val()
		var createTime =  $("#createTime").val()
		
		return {
			rows : params.limit, // 页面大小
			page : params.pageNumber, // 页码
			id : id,
			orderCode : orderCode,
			payCode : payCode,
			payTime : payTime,
			payMoney : payMoney,
			payType : payType,
			filePath : filePath,
			accountName : accountName,
			bankAccount : bankAccount,
			bankName : bankName,
			openBank : openBank,
			confirmStatus : confirmStatus,
			approverCoee : approverCoee,
			approveResult : approveResult,
			aporoveReason : aporoveReason,
			approveTie : approveTie,
			isDelete : isDelete,
			creater : creater,
			createTime : createTime
		};
	};
	
	var url = rootPath + "/orderPay/listOrderPayPage"; // 请求json数据的服务器地址
	sys.initTable('orderPayTable', {
		url : url,
		queryParams : queryParams,
		columns : columns,
		striped : true,
		clickToSelect : true
	});

	// 查询
	$('#btnQuery').on('click', function() {
		sys.reloadTable('orderPayTable');
	});
	
	// 清空
	$('#btnClear').on('click', function() {
		$("#id").val("");
		$("#orderCode").val("");
		$("#payCode").val("");
		$("#payTime").val("");
		$("#payMoney").val("");
		$("#payType").val("");
		$("#filePath").val("");
		$("#accountName").val("");
		$("#bankAccount").val("");
		$("#bankName").val("");
		$("#openBank").val("");
		$("#confirmStatus").val("");
		$("#approverCoee").val("");
		$("#approveResult").val("");
		$("#aporoveReason").val("");
		$("#approveTie").val("");
		$("#isDelete").val("");
		$("#creater").val("");
		$("#createTime").val("");
	});

	$('#btnAdd').on('click', function() {
		sys.showRemote(rootPath + '/orderPay/toAddOrderPay', function() {
			var key = sys.dialog.getData("key");
			if (key == '1') {
				showSuccess("添加成功！", sys.reloadTable('orderPayTable'));
			} else if (key == '0') {
				showErr("添加失败！");
			}
		}, {
			title : '新增订单付款',
			width : 600,
			height : 600
		});

	});

})

// 跳转编辑页面
function toEdit(id) {
	window.location.href = rootPath + "/orderPay/toUpdateOrderPay?id=" + id;
}